<template>
    <view class="uni-padding-wrap uni-common-pb">
        <form @submit="formSubmit" @reset="formReset">
            <view class="uni-header-logo">
                <image src="../../../static/msg2.png"></image>
            </view>
            <view class="uni-hello-text uni-common-pb">
                1发祝福，上大屏，祝福写得越好越容易中大奖哦！
            </view>
            <view class="uni-textarea">
                <textarea @input="bindTextAreaBlur" auto-height />
            </view>
            <view class="uni-btn-v">
                <button class="btn-submit" :disabled="isDisabled" formType="submit" type="primary">发送1</button>
                <!-- <button type="primary" @tap="bindpostBless">发送</button> -->
            </view>
        </form>
    </view>
</template>
<script>
import {get,post} from '@/utils/index';
import {getActDetails,getSignList,postBless} from '@/utils/api';
export default {
    data(){
        return{
            text: '',
            postData:{
                message:'',
                act_id:3,
                uid:145,
                avatarUrl:'',
                isDisabled:true
            }
        }
    },
    mounted(){
        this.init()
    },
    methods:{
        init(){
            let user  = uni.getStorageSync('userInfo')
            this.postData.avatarUrl = user.avatarUrl
        },
        test(){
            console.log(this.postData)
        },
        bindTextAreaBlur: function (e) {
            // console.log(e.detail.value)
            this.postData.message = e.detail.value
        },
        formSubmit: function (e) {
            // uni.showToast({ title: 'sdfsdfdsf', icon: "none" })
            //将下列代码加入到对应的检查位置
            //定义表单规则
            var rule = [
                {name:"name", checkType : "string", checkRule:"1,4",  errorMsg:"姓名应为1-4个字符"}
            ];
            //进行表单检查
            var formData = e.detail.value
            var checkRes = graceChecker.check(formData, rule)
            if(checkRes){
                // this.login()
                uni.showToast({title:"验证通过!", icon:"none"})
            }else{
                uni.showToast({ title: graceChecker.error, icon: "none" })
            }
        },
        bindpostBless:function(){
            post(postBless,this.postData, true)
            .then((res)=>{
                uni.showModal({
                    title: '提示',
                    content: '发送成功',
                    showCancel:false,
                    success: function (res) {
                        // uni.switchTab({
                        //     url: '/pages/tabBar/act/act'
                        // });
                    }
                });
            })
        }
    }
}
</script>
<style>

</style>

